package Demo_zhuanshu01.X8;

public class Demo3 implements Runnable{
 
    @Override
    public void run() {
        for(int i=0;i<10;i++) {
            String name= Thread.currentThread().getName();
            System.out.println(name+(i+1)+"号病人在看病！");
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
 
class Demo3Test{
    public static void main(String[] args) {
        Demo3 demo3 = new Demo3();
        Thread vip = new Thread(demo3, "专家号:");
        vip.setPriority(10);
        vip.start();
        for (int i = 0; i < 50; i++) {
            if (i == 10) {
                try {
                    vip.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            String name = Thread.currentThread().getName();
            System.out.println("普通号："+(i + 1) + "号病人在看病！");
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
 